import java.util.*;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        TreeSet<String> set = new TreeSet<>();
        set.add("abc");
        set.add("def");
        set.add("hello");
        set.add("hello");
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next()+" ");
        }

    }

    public static void main2(String[] args) {
        //底层是二叉搜索树 每次存放元素 都要进行大小比较  -》 key的值进行比较
        TreeMap<String,Integer> map = new TreeMap<>();
        map.put(null,4);
        map.put("def",4);
        map.put("abc",6);
        map.put("abc",16);

        //根据key获取val值
        Integer integer = map.get("abc");
        System.out.println(integer);

        integer = map.getOrDefault("abcd",9999);
        System.out.println(integer);

        /*Integer rev = map.remove("abc");
        System.out.println(rev);*/

        //Set 集合 ： 存放在这个集合类中的 都是自动去重的
        Set<String> set = map.keySet();
        System.out.println(set);

        Collection<Integer> collection = map.values();
        System.out.println(collection);

        //Set<Map.Entry<K, V>> entrySet()
        Set< Map.Entry<String, Integer> > entrySet = map.entrySet();
        for(Map.Entry<String, Integer> entry : entrySet) {
            System.out.println("key: "+entry.getKey()+" value: " + entry.getValue());
        }
        System.out.println("=====");
        System.out.println(map);
    }



    public static void main1(String[] args) {
        int[] array = {10,5,12,13,6};

        BinarySearchTree binarySearchTree = new BinarySearchTree();
        for(int x: array) {
            binarySearchTree.insert(x);
        }
        BinarySearchTree.TreeNode search = binarySearchTree.search(12);
        System.out.println(search.val);

        binarySearchTree.remove(10);

        System.out.println("1234567890");
    }
}
